package com.example.controller;

import com.example.consts.RbmConsts;
import com.example.pojo.dto.GeekJobDTO;
import com.example.pojo.entity.Post;
import com.example.service.GeekJobService;
import com.example.vo.Result;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 用于演示 :
 *
 * @author : gao'm
 */
@RestController
@RequestMapping("GeekJ")
public class GeekJobController {
    @Autowired
    private GeekJobService geekJobService;
    @Autowired
    private RabbitTemplate rabbitTemplate;

    @GetMapping("geekjob")
    public Result findAll(Integer jsId,String searchkey){
//        System.out.println("搜索:");
//        System.out.println(searchkey);

        System.out.println(jsId);
        System.out.println(searchkey);
        String search = jsId+","+searchkey;
        List<GeekJobDTO> posts = geekJobService.getAll(searchkey);
        if (searchkey!=null && searchkey!=""&&jsId!=null){
            rabbitTemplate.convertAndSend(RbmConsts.ROOTING_EX,RbmConsts.ROOTING_DH_SEARCH_RK,search);
        }

        return new Result(200,"查询成功",posts);
    }

    @GetMapping("sameCompanyJob")
    public Result findAllSame(String companyName){
        List<GeekJobDTO> samejobs = geekJobService.findSamePost(companyName);
        return new Result(200,"查询成功",samejobs);

    }
}